﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace community_severvice_exchange
{
    public class UserLogin
    {
        User user = null;
        private string _input_username;
        private string _input_psw;
        private Boolean isUser = false;
        public List<User> list_users = new List<User>();

        public UserLogin(string username,string psw)
        {
            this._input_username = username;
            this._input_psw = psw;
        }

       
        
        public bool check()
        {
            FileStream f = new FileStream("users.txt",FileMode.Open,FileAccess.Read);
            using (StreamReader sr = new StreamReader(f))
            {
                string[] temp = null;
                string line = null;
                while ((line=sr.ReadLine()) != null)
                {
                    temp=line.Split('+');
                    if ((temp[0].Equals(_input_username)) && (temp[1].Equals(_input_psw)))
                    {
                        isUser = true;
                        break;
                    }
                    else 
                    { isUser = false; }
                }
            }
            return isUser;
        }
    }
}
